package org.ainlolcat.ainscience.entity;

import org.jdom.Element;

import java.util.Hashtable;

/**
 * Created by IntelliJ IDEA.
 * User: ain
 * Date: 05.03.12
 * Time: 1:01
 * To change this template use File | Settings | File Templates.
 */
public class EntityDescriptionRegister {
    Hashtable<String,Element> descriptions;
    private static EntityDescriptionRegister instance;
    
    private EntityDescriptionRegister(){
        descriptions = new Hashtable<String, Element>();    
    }
    
    public EntityDescriptionRegister getInstance(){
        if (instance == null){
            instance = new EntityDescriptionRegister();
        }
        return instance;
    }
    
    public boolean hasDescriptionFor(String name){
        return descriptions.containsKey(name);
    }
    
    public boolean registerEntity(String name, Element description){
        if (hasDescriptionFor(name)) return false;
        descriptions.put(name, description);
        return true;
    }
}
